package PTA.Mianxiangduixiang.ex21;

import java.net.InetAddress;
import java.util.Scanner;
public class ex21
{
    public static void main( String[] args )
    {
      Scanner sc = new Scanner(System.in);
      String line = sc.nextLine();
      String str[] =line.split(" ");
      int arr[] = new int[1024];
      int max = 0;
      int min = 0;
      int indexmax = 0;
      int indexmin = 0;
      int temp=0;
      int temp2 =0;
      for(int i=0;i<str.length;i++){
          System.out.println(str[i]);
         arr[i] = Integer.parseInt(str[i]);
          if(arr[i]>=max){
indexmax = i;
max = arr[i];//最大值
          }
          if(arr[i]<=min){
              indexmin = i;
              min = arr[i];//最小值
          }
      }
      temp = arr[0];
      arr[0] = max;
      arr[indexmax] = temp;

      temp2 = arr[str.length-1];
      arr[str.length-1] = min;
      arr[indexmin] = temp2;

for(int i=0;i<str.length;i++){
    System.out.println(arr[i]);
}
    }
}